# Contributor: Dennis Krupenik <dennis@krupenik.com>
# Maintainer: Dennis Krupenik <dennis@krupenik.com>
pkgname=one-dnn
pkgver=2.5
pkgrel=0
pkgdesc="oneAPI Deep Neural Network Library"
url="https://01.org/oneDNN"
# Used to executed primitives on Intel 64bit, aarch64 and compatible devices
arch="x86_64"
license="Apache-2.0"
depends_dev="libtbb-dev opencl-headers opencl-icd-loader-dev"
makedepends="cmake samurai $depends_dev"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/oneapi-src/oneDNN/archive/v$pkgver/oneDNN-$pkgver.tar.gz"
builddir="$srcdir/oneDNN-$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	# if not release type, debug is selected
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_VERBOSE_MAKEFILE=ON \
		-DDNNL_GPU_RUNTIME=OCL \
		-DDNNL_CPU_RUNTIME=TBB \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	ctest -E '(gpu|cross-engine|api)' --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
49b0730d1af1e6ba18b9ae3c1f43430a4e22d581e5b540323db2b053fa58915a42a1797974e59c508e85e0ee6ddb61020d570df6cd956a97a19f2a8435d10ef1  oneDNN-2.5.tar.gz
"
